﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;

using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using Cn.Edwon.Web.Support;
using Cn.Cellula.Model;
using Cn.Edwon.Biz;
using Cn.Edwon.Spring;
using Cn.Cellula.Website.Ws;
using Cn.Cellula.Model.System;

namespace Cn.Cellula.Website.Admin.Content.Action {
    public partial class Test : PageSupport {
        IBiz biz = BizFactory.Get<IBiz>();
        protected void Page_Load(object sender, EventArgs e) {
            if (!Page.IsPostBack) {
                InitForm();
            }
        }
        private void InitForm() {
            TSysActionEO eo = biz.Load<TSysActionEO>(Request.QueryString["id"]);
            this.txt_Hql.Text = eo.Hql;
            this.lab_Type.Text = eo.ActionType;
            this.lab_Title.Text = eo.ActionName;
            this.lab_Key.Text = eo.ActionKey;
        }

        protected void btn_Test_Click(object sender, EventArgs e) {
            try {
                _Action act = new _Action();
                String hql = act.BuildHql(this.txt_Hql.Text, this.txt_Parms.Text);
                this.txt_Hql.Text = hql;
                this.txt_Result.Text = act.BuildJson(hql,this.lab_Type.Text);
            } catch (Exception ex) {
                this.txt_Result.Text = ex.Message+"\n"+ex.StackTrace;
            }
        }
    }
}
